package com.project.petLossSystem.util;

import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.springframework.web.client.RestTemplate;

public class RestTemplateUtil {
    public static Rect getRect(String url) {
        RestTemplate restTemplate = new RestTemplate();
        String response = restTemplate.getForObject(url, String.class);
        if (response.equals("null")) {
            return null;
        }
        String[] arr = response.split(",");
        double x1 = Double.parseDouble(arr[0].substring(1)); // 去除[
        double y1 = Double.parseDouble(arr[1]);
        double x2 = Double.parseDouble(arr[2]);
        double y2 = Double.parseDouble(arr[3].substring(0, arr[3].length() - 2)); // 去除]还有一个换行符
        return new Rect(new Point(x1, y1), new Point(x2, y2));
    }
}
